package testGUI;



import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;

import de.szut.bomberman.graphics.gamefield.Field;
import de.szut.bomberman.graphics.gamefield.PlayerOne;
import de.szut.bomberman.graphics.gamefield.PlayerTwo;
import de.szut.bomberman.graphics.gamefield.Stone;

public class GamePanel extends JLayeredPane {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4548766038666005791L;
	private JLabel playerOne;
	private JLabel playerTwo;
	
	private ArrayList<Point> stonePositions;

	
	public GamePanel() {
		stonePositions = new ArrayList<Point>();
		
		setLayout(null);
		
		JLabel field = new JLabel(new ImageIcon(new Field().getTexture()));
		field.setLocation(0, 0);
		field.setSize(600, 600);
		add(field, new Integer(0));
		Stone stone = new Stone();
		for (int y = 0; y < 12; y++) {
			for (int x = 0; x < 12; x++) {
				if (x % 2 == 0 && y % 2 == 0) {
					JLabel stoneLabel = new JLabel(new ImageIcon(
							stone.getTexture()));
					stoneLabel.setSize(50, 50);
					stoneLabel.setLocation(x * 50, y * 50);
					add(stoneLabel, new Integer(1));
					stonePositions.add(new Point(x * 50, y * 50));
					
				}
			}
		}
		playerOne = new JLabel(new ImageIcon(new PlayerOne().getTexture()));
		playerOne.setLocation(50, 100);
		playerOne.setSize(50, 50);
		add(playerOne, new Integer(1));
		
		playerTwo = new JLabel(new ImageIcon(new PlayerTwo().getTexture()));
		playerTwo.setLocation(540, 540);
		playerTwo.setSize(50, 50);
		add(playerTwo, new Integer(1));
		
		addKeyListener(new Listener(playerOne, playerTwo, stonePositions, this));

		
	}
}
